<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
// function fun(){
//     console.log(1111);
//     fun();
// }
// fun();

//1+2+3+4+5=?==>n+(n-1)
function fun1(n){
    console.log(n);
    //结束条件
    if(n===1){
        return 1;
    }else{
        return n*fun1(n-1);
        //5+fun1(4)
        //4+fun1(3)
        //3+fun1(2)
        //2+fun1(1)
        //1
        //fun1(1)=1  fun1(2)=fun1(1)+2=1+2
    }

}
console.log(fun1(100));
</script>
</body>
</html>